//
//  BCPayStyleCell.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/21.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCPayStyleCell.h"

@interface BCPayStyleCell ()
{
    UILabel *aliPay;
    UILabel *netBank;
    UIButton *aliButton;
    UIButton *netButton;
    UIView *backView;
}
@end

@implementation BCPayStyleCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    aliPay = [[UILabel alloc] init];
    aliButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [aliButton setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateSelected];
    [aliButton setImage:[UIImage imageNamed:@"未选择"] forState:UIControlStateNormal];
    netBank = [[UILabel alloc] init];

    netButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [netButton setImage:[UIImage imageNamed:@"选中"] forState:UIControlStateSelected];
    [netButton setImage:[UIImage imageNamed:@"未选择"] forState:UIControlStateNormal];
    
    [aliButton addTarget:self action:@selector(changeBack:) forControlEvents:UIControlEventTouchUpInside];
    [netButton addTarget:self action:@selector(changeBack:) forControlEvents:UIControlEventTouchUpInside];
    aliPay.text = @"   支付宝";
    aliPay.font = [UIFont systemFontOfSize:16];
    aliPay.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    netBank.text = @"   银联在线支付";
    netBank.font = [UIFont systemFontOfSize:16];
    netBank.textColor = [UIColor colorWithRed:0.200  green:0.200  blue:0.200 alpha:1];
    
    backView = [[UIView alloc] init];
    aliPay.backgroundColor = [UIColor whiteColor];
    netBank.backgroundColor = [UIColor whiteColor];
    [backView addSubview:aliPay];
    [backView addSubview:aliButton];
    [backView addSubview:netBank];
    [backView addSubview:netButton];
    
        backView.backgroundColor = [UIColor colorWithRed:0.957  green:0.957  blue:0.957 alpha:1];
    [self.contentView addSubview:backView];
}

- (void)changeBack:(UIButton *)but
{
    but.selected = !but.selected;
}

- (void)layoutSubviews
{
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.bottom.and.left.and.right.mas_equalTo(0);
        
    }];
    
    [aliPay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(40);

    }];
    
    [aliButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(aliPay.mas_centerY);
        make.width.and.height.mas_equalTo(20);
        make.right.mas_equalTo(-28);
    }];
    [netBank mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(aliPay.mas_bottom).with.offset(2);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(40);
        
    }];
    
    [netButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(netBank.mas_centerY);
        make.width.and.height.mas_equalTo(20);
        make.right.mas_equalTo(-28);
    }];

    
    
}

@end
